﻿<DemoPageSectionComponent Id="Editors-CheckBox-BindToEnum" ShowSizeMode="true">
    <ChildContentWithParameters Context="Params">
        <div>
            <DxCheckBox @bind-Checked="@Value"
                        AllowIndeterminateStateByClick="true"
                        CssClass="mb-1"
                        ValueChecked="@Opinion.Yes"
                        ValueUnchecked="@Opinion.No"
                        ValueIndeterminate="@Opinion.Abstain"
                        SizeMode="Params.SizeMode">
                @GetText()
            </DxCheckBox>

            <DxCheckBox Checked="Opinion.Yes"
                        Enabled="false"
                        CssClass="mb-1"
                        ValueChecked="@Opinion.Yes"
                        ValueUnchecked="@Opinion.No"
                        ValueIndeterminate="@Opinion.Abstain"
                        SizeMode="Params.SizeMode">
                Disabled Checked
            </DxCheckBox>

            <DxCheckBox Checked="Opinion.No"
                        Enabled="false"
                        CssClass="mb-1"
                        ValueChecked="@Opinion.Yes"
                        ValueUnchecked="@Opinion.No"
                        ValueIndeterminate="@Opinion.Abstain"
                        SizeMode="Params.SizeMode">
                Disabled Unchecked
            </DxCheckBox>

            <DxCheckBox Checked="Opinion.Abstain"
                        Enabled="false"
                        CssClass="mb-1"
                        ValueChecked="@Opinion.Yes"
                        ValueUnchecked="@Opinion.No"
                        ValueIndeterminate="@Opinion.Abstain"
                        SizeMode="Params.SizeMode">
                Disabled Indeterminate
            </DxCheckBox>
        </div>
    </ChildContentWithParameters>

    @code{
        enum Opinion { Yes, No, Abstain }
        Opinion Value = Opinion.Abstain;

        string GetText() {
            if (Value == Opinion.Yes)
                return "Checked";
            if (Value == Opinion.No)
                return "Unchecked";
            return "Indeterminate";
        }
    }
</DemoPageSectionComponent>
